package com.kj.mynote.View;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.text.method.KeyListener;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.EditText;

import com.kj.mynote.R;

/**
 * @author wy
 * @version V1.0
 * @Title: MyApplication
 * @Package com.kj.mynote
 * @Description: TODO(用一句话描述该文件做什么)
 * @date 17/3/22 09:03
 */

public class LineEditText extends EditText {

    private Paint linePaint;
    private int paperColor;

    public LineEditText(Context paramContext, AttributeSet paramAttributeSet) {
        super(paramContext, paramAttributeSet);
        this.linePaint = new Paint();
        linePaint.setColor(getResources().getColor(R.color.colorPrimary));
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        int speSize = MeasureSpec.getSize(heightMeasureSpec);
        setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), speSize);

    }

    protected void onDraw(Canvas paramCanvas) {
        int paddingLeft = getPaddingLeft();
        int paddingRight = getPaddingRight();
        int spacing = (int) getLineSpacingExtra();
        setPadding(paddingLeft, 0, paddingRight, 0);
        paramCanvas.drawColor(this.paperColor);
        int i = getLineCount();
        int j = getHeight();
        int k = getLineHeight();
        int m = 1 + j / k;
        if (i < m) {
            i = m;
        }
        int n = getCompoundPaddingTop() ;
        paramCanvas.drawLine(0.0F, n, getRight(), n, this.linePaint);
        for (int i2 = 0; ; i2++) {
            if (i2 >= i) {
                super.onDraw(paramCanvas);
                paramCanvas.restore();
                return;
            }
            n += k;
            paramCanvas.drawLine(0.0F, n, getRight(), n, this.linePaint);
            paramCanvas.save();
        }
    }

}